import 'package:flutter/material.dart';
import 'package:flutter_getx_cms/pages/workbench/view.dart';
import 'package:get/get.dart';

import '../res/assets_path.dart';
import 'home/view.dart';
import 'main_controller.dart';


class GetMainPage extends StatelessWidget {
  GetMainPage({Key? key}) : super(key: key);


  /// 使用Get.put()实例化你的类，使其对当下的所有子路由可用。
  final logic = Get.put(GetMainLogic());

  @override
  Widget build(BuildContext context) {
    return  WillPopScope(
      onWillPop: () async {
        // 禁止返回
        return false;
      },
      child:Scaffold(
        bottomNavigationBar: Obx(() => BottomNavigationBar(
          currentIndex: logic.pageIndex.value,
          items: _getItems(),
          // selectedItemColor: themeData.brandColor6,
          // unselectedItemColor: themeData.grayColor6,
          showSelectedLabels: true,
          showUnselectedLabels: true,
          onTap: (index) => logic.pageChange(index),
        )),
        body: Obx(
              () => Stack(
            children: [
              pages[logic.pageIndex.value],
            ],
          ),
        ),
      ),
    );

  }


  List<BottomNavigationBarItem> _getItems() => [
    BottomNavigationBarItem(
        icon: Image.asset(
          R.IMAGES_HOME_UNCHECKED_PNG,
          width: 20,
        ),
        activeIcon: Image.asset(
          R.IMAGES_HOME_CHECKED_PNG,
          width: 20,
        ),
        label: "首页".tr),
    BottomNavigationBarItem(
        icon: Image.asset(
          R.IMAGES_WORKBENCH_UNCHECKED_PNG,
          width: 20,
        ),
        activeIcon: Image.asset(
          R.IMAGES_WORKBENCH_CHECKED_PNG,
          width: 20,
        ),
        label: "工作台".tr),
  ];

  List<Widget> pages = [
    GetHomePage(),
    GetWorkbenchPage(),
  ];



}
